/**
 * test `for` in java
 * @author kelvin
 *
 */
public class Java_for_Test {

	public static void intToByte1(long i, byte[] bytes, int index) {
		bytes[index] = (byte) (0xff & i);
	}

	public static void main (String [] args){
		run();
	}
	public static void run()
	{
		long[][] longss = new long[1][12];
		byte[] bytes = new byte[longss.length * 40];

		long t1 = System.currentTimeMillis();
		for (int c=0;c<100000 ;c++ ) {

			int mark = 0;
			intToByte1(longss[0][2],bytes, mark);
			mark++;
			intToByte1(longss[0][3],bytes, mark);
			mark++;
			intToByte1(longss[0][4],bytes, mark);
			mark++;
			intToByte1(longss[0][5],bytes, mark);
			mark++;
			intToByte1(longss[0][6],bytes, mark);
			mark++;
			intToByte1(longss[0][7],bytes, mark);
			mark++;
			intToByte1(longss[0][8],bytes, mark);
			mark++;
			intToByte1(longss[0][9],bytes, mark);
			mark++;
			intToByte1(longss[0][10],bytes, mark);
			mark++;
			intToByte1(longss[0][11],bytes, mark);
			mark++;
		}
		long t2 = System.currentTimeMillis();

		for (int c=0;c<100000 ;c++ ) {
			int mark = 0;
			for (int i = 2 ; i < 12 ; i++ ) {
				intToByte1(longss[0][i],bytes, mark);
				mark++;
			}}

			long t3 = System.currentTimeMillis();

			long t2_t1 = t2 -t1,
				 t3_t2 = t3 - t2;

			System.out.println("T1=="+t2_t1);
			System.out.println("T2(for)=="+t3_t2);
			System.out.println("using `for` is "+(t3_t2 < t2_t1 ?"":"**no**")+"quicker than not.\n");
	}

}
